/**
 * Created by CK on 2017/5/24.
 */
$(document).ready(function(){
    var source      = {url: baseUrl + 'Stats/getChartTotalLogin'},
        defaultType = xhTool.getQuery('userType'),
        userParams  = {},
        userType    = [],
        btViewDom   = $('#bt_user_view');

    if(btViewDom.length < 1){
        $('body').css('background-color', 'white');
    }
    if(defaultType){
        $(':checkbox').prop('checked', false);
        $(':checkbox[value='+ defaultType +']').prop('checked', true);
        userType.push(defaultType);
        userParams.userType = userType;
        renderUserInfo();
    }
    btViewDom.click(function(){
        userType = [];
        $(':checkbox:checked').each(function(){
            userType.push($(this).val());
        });
        userParams.userType  = userType;
        userParams.startDate = $(':input[name=startDate]').val();
        userParams.endDate   = $(':input[name=endDate]').val();
        renderUserInfo();
    });
    function renderUserInfo(){
        source.params = userParams;
        (new xhChart).pie('chart', source, {showLegends: false}, {
            series: [{
                itemStyle: {
                    normal: {
                        label: {
                            //formatter: '{b}',
                            position: 'outside'
                        }
                    }
                }
            }]
        });
    }
});